﻿using System;
using System.Diagnostics;
using battlenet.wow.rt.domain.objects;
using battlenet.wow.rt.sdk.data.dto;
using battlenet.wow.rt.sdk.utility;

namespace battlenet.wow.rt.sdk.objects.Mapper
{
    internal class CharacterProfileMapper : Remapper<WowCharacter>
    {
        public override void RegisterMappers()
        {
            Register(typeof(CharacterProfileInfo), input => Map(input as CharacterProfileInfo));
        }

        internal WowCharacter Map(CharacterProfileInfo info)
        {
            Debug.WriteLine(string.Format("Mapping {0}'s profile...", info.Name));
            var character = new WowCharacter();
            character.LastModified = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(info.LastModified);
            character.Name = info.Name;
            character.Realm = info.Realm;
            character.Battlegroup = info.Battlegroup;
            character.Class = Classes.Class[info.Class];
            character.Race = Races.Race[info.Race];
            character.Gender = (GenderType) info.Gender;
            character.Level = info.Level;
            character.AchievementPoints = info.AchievementPoints;
            character.Thumbnail = info.Thumbnail;
            character.CalcClass = info.CalcClass;
            character.HonorableKills = info.TotalHonorableKills;
            character.Items = info.Items.Remap(new CharacterItemMapper());
            Debug.WriteLine(string.Format("Mapping {0}'s profile completed!", info.Name));
            return character;
        }
    }
}